from peft import LoraConfig, TaskType, get_peft_model

config = LoraConfig(
    task_type=TaskType.CAUSAL_LM,        # 指定任务类型为因果语言模型
    target_modules=[                     # 指定应用LoRA的层
        "q_proj", "k_proj", "v_proj", 
        "o_proj", "gate_proj", "up_proj", "down_proj"
    ], 
    inference_mode=False,                # 设置为训练模式
    r=8,                                 # LoRA秩
    lora_alpha=32,                       # LoRA缩放因子
    lora_dropout=0.1                     # Dropout比例,用于防止过拟合
)
